import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '申请单ID',
    align:"center",
    dataIndex: 'wmPurchaseRequisitionId',
    defaultHidden: true
   },
   {
    title: '需求池流水号',
    align:"center",
    dataIndex: 'requisitionDetailCode'
   },
   {
    title: '物料',
    align:"center",
    dataIndex: 'wmMaterialId'
   },
   {
    title: '申请数量',
    align:"center",
    dataIndex: 'applyQuantity'
   },
   {
    title: '采购员',
    align:"center",
    dataIndex: 'purchaserId_dictText'
   },
   {
    title: '参考供应商',
    align:"center",
    dataIndex: 'suggestSupplier'
   },
   {
    title: '到货日期',
    align:"center",
    dataIndex: 'arrivalDate',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '是否进入需求池',
    align:"center",
    dataIndex: 'isActivate',
    customRender:({text})=>{
      return text==1?'是':'否'
    }
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '申请单ID',
    field: 'wmPurchaseRequisitionId',
    component: 'Input',
    show:({values})=>{
      return values.id
    },
    componentProps:{
      disabled:true
    }
  },
  {
    label: '需求池流水号',
    field: 'requisitionDetailCode',
    component: 'Input',
    show:({values})=>{
      return values.id
    },
    componentProps:{
      disabled:true
    }
  },
  {
    label: '物料ID',
    field: 'wmMaterialId',
    component: 'Input',
  },
  {
    label: '申请数量',
    field: 'applyQuantity',
    component: 'InputNumber',
  },
  {
    label: '采购员',
    field: 'purchaserId',
    required:true,
    component: 'JSelectUser',
    componentProps: {
      multiple: '0',
      isRadioSelection:true,
      rowKey: 'id',
      labelKey: 'realname',
      maxSelectCount: 1,
    },
  },
  {
    label: '参考供应商',
    field: 'suggestSupplier',
    component: 'Input',
  },
  {
    label: '到货日期',
    field: 'arrivalDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    label: '是否进入需求池',
    field: 'isActivate',
    defaultValue:1,
    component: 'JSwitch',
    componentProps:{
      options:[1,0]
    }
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  wmPurchaseRequisitionId: {title: '申请单ID',order: 0,view: 'text', type: 'string',},
  requisitionDetailCode: {title: '需求池流水号',order: 1,view: 'text', type: 'string',},
  applyQuantity: {title: '申请数量',order: 3,view: 'number', type: 'number',},
  purchaserId: {title: '采购员',order: 4,view: 'text', type: 'string',},
  suggestSupplier: {title: '参考供应商',order: 5,view: 'text', type: 'string',},
  arrivalDate: {title: '到货日期',order: 6,view: 'date', type: 'string',},
  remark: {title: '备注',order: 7,view: 'text', type: 'string',},
  isActivate: {title: '是否进入需求池 0 否 1是',order: 8,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}